﻿@using System.Reflection
@using ClothingAggregator.Models
@using ClothingAggregator.Utils
@model MySearchData

@{
    ViewBag.Title = "Wyszukiwarka ubrań";
}
<script type="text/javascript" src="~/Content/Scripts/HomeScript.js"></script>
<script type="text/javascript" src="~/Content/Scripts/pagination.js"></script>
<script>
    $(document).ready(function () {
        $("#toggleAdvancedSearch").click(function () {
            $(this).find("span.arrow").toggleClass('hidden');
            $("#advancedSearch").slideToggle();
        });
        pagination(@ViewBag.PageCount);
    });
</script>


@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)

    <div class="page">
        <div id="search">
            <h2>Wyszukiwarka ubrań</h2>

            <div class="editor-label">
                @Html.LabelFor(model => model.Category)
            </div>
            <div class="editor-field">
                @Html.DropDownListForEnum(model => model.Category, typeof(ClothingCategory))
                @Html.ValidationMessageFor(model => model.Category)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Color)
            </div>
            <div class="editor-field">
                @Html.DropDownListForEnum(model => model.Color, typeof(ClothingColor))
                @Html.ValidationMessageFor(model => model.Color)
            </div>

            <div class="clear"></div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Size)
            </div>
            <div class="editor-field">
                @Html.DropDownListForEnum(model => model.Size, typeof(ClothingSize))
                @Html.ValidationMessageFor(model => model.Size)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.Sex)
            </div>
            <div class="editor-field">
                @Html.DropDownListForEnum(model => model.Sex, typeof(ClothingSex))
                @Html.ValidationMessageFor(model => model.Sex)
            </div>

            <div class="clear"></div>

            <!-- ADVANCED SEARCH -->
            <div id="toggleAdvancedSearch"><span class="arrow hidden">▲</span><span class="arrow">▼</span>Szczegółowe opcje wyszukiwania</div>
            <div id="advancedSearch">
                <div class="editor-label">
                    @Html.LabelFor(model => model.Age)
                </div>
                <div class="editor-field">
                    @Html.DropDownListForEnum(model => model.Age, typeof(ClothingAge))
                    @Html.ValidationMessageFor(model => model.Age)
                </div>

                <div class="clear"></div>

                <div class="editor-label">
                    Cena od - do
                </div>
                <div class="editor-field short-input">
                    @Html.EditorFor(model => model.PriceMin)
                    @Html.EditorFor(model => model.PriceMax)
                </div>

                <div class="clear"></div>
            </div>
            <p>
                <input type="submit" name="searchSubmit" value="Szukaj!" />
            </p>
        </div>
        @Html.DropDownListForSortableProperties(model => model.OrderBy, ViewBag.Props as IEnumerable<PropertyInfo>)
        @Html.DropDownListForEnum(model => model.SortingDirection, typeof(SortingDirection))
        @if (IsPost)
        {
            <div class="navigationButtons"></div>
            foreach (MyAdvertisement ad in ViewBag.Results)
            {
            <div class="ad">
                <div class="siteLogo">
                    <img src="@Url.Content("~/Content/Img/" + ad.AdSource + ".png")" alt=""/>
                </div>
                <div class="preview">
                    <img src="@ad.Photo" height="200" alt="@ad.Title"/>
                </div>
                <div class="info">
                    <span><a href="@ad.Link" target="_blank">@ad.Title</a></span>
                    <span>Cena: @ad.Price</span>
                </div>
            <a class="monitor"></a>
            </div>
            }

            <div class="navigationButtons clear"></div>
            @Html.HiddenFor(model => model.Page)
            <div id="dialog-monitor"title="Monitorowanie ceny">
                <p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Czy chcesz monitorować cenę tego produktu?</p>
            </div>
             <div id="dialog-monitoring" class="dialog-message" title="Monitorowanie ceny">
              <p class="message-content"></p>
            </div>
        }
    </div>
}

